package com.bltec.emergency.mapper;

import com.bltec.emergency.model.Maps;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface MapsMapper {
    //插入一条Maps记录
    @Insert("insert into maps (name,location,create_by,create_time,enable) " +
            "values(#{name},#{location},#{createBy},#{createTime},#{enable})")
    boolean insert(Maps maps);

    //通过id设置一条记录为不可用
    @Update("update maps set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update maps set name=#{name},location=#{location}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateMapsById(Maps maps);

    //查找符合id字段的记录
    @Select("select id,name,location,create_by,create_time,update_by,update_time,enable" +
            " from maps where id =#{id} and enable=1")
    Maps getMapsById(Long id);

    //查找所有记录
    @Select("select id,name,location,create_by,create_time,update_by,update_time,enable" +
            " from maps where enable=1")
    List<Maps> selectAll();
}